<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Category extends CI_Controller {

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     * 		http://example.com/index.php/welcome
     * 	- or -  
     * 		http://example.com/index.php/welcome/index
     * 	- or -
     * Since this controller is set as the default controller in 
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see http://codeigniter.com/user_guide/general/urls.html
     */
    function __construct() {
        parent::__construct();
        $this->load->model('m_hoa');
        $this->load->model('m_loaihoa');
        $this->load->library('pagination');
        $this->load->helper('url');
    }

    function index() {        
        $config['base_url'] = base_url('index.php/category'); // xác định trang phân trang 
        $config['total_rows'] = $this->m_hoa->count_all(); // xác định tổng số record 
        $config['per_page'] = 15; // xác định số record ở mỗi trang 
        $config['uri_segment'] = 2; // xác định segment chứa page number 
        $this->pagination->initialize($config);
        $data['hoa'] = $this->m_hoa->list_all($config['per_page'], $this->uri->segment(2));
        $data['category'] = $this->m_loaihoa->getAllCategory();       
        $this->load->view('category', $data);
    }
    

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */